<%@ page language="java" pageEncoding="UTF-8" %>
<%@ page import="org.springframework.context.*" %>
<%@ page import="org.springframework.web.context.support.*" %>
<%@ page import="java.util.List" %>
<%@ page import="cn.edu.seig.UserController" %>
<%@ page import="cn.edu.seig.User" %>
<%@ page isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Druid数据源测试</title>
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <script src="js/jquery.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
</head>

<body>
<%
    //获取Web应用初始化的Spring容器
    ApplicationContext ac = WebApplicationContextUtils.getWebApplicationContext(application);
    //取容器中id为userController的Bean
    UserController userController = (UserController) ac.getBean("userController");
    List<User> userList = userController.findAllUser();
    application.setAttribute("userList", userList);
%>
<h2 align="center">后台管理-用户管理</h2>
<a href='userAdd'><img src="img/add.png"></a>
<div id="logout" align="right"><a href="logout">注销</a></div>
<table class="table  table-bordered" align="center" valign="middle">
    <thead>
    <tr>
        <th scope="col">序号</th>
        <th scope="col">用户ID</th>
        <th scope="col">姓名</th>
        <th scope="col">个人图像</th>
        <th scope="col">操作</th>
    </tr>
    </thead>
    <tbody>
    <c:forEach items="${userList}" var="u" varStatus="s">
        <form name='form' action=''>
            <input type="hidden" name="id" value="${u.userId}"/>
            <tr>
                <th scope="row">${s.index+1 }</th>
                <td><a href="">${u.userId}</a></td>
                <td>${u.userName}</td>
                <td><a href="#" style="text-decoration:none">
                    <img src="img/s7.jpg" alt="个人图像" width="100" height="100"/>
                    </a>
                </td>
                <td><img src="img/edit.png"><img src="img/delete.png"></td>
            </tr>
        </form>
    </c:forEach>
    </tbody>
</table>
</body>
</html>